package com.wskh.edu.controller;


import com.wskh.commonUtil.R;
import com.wskh.edu.mapper.StatisticsDailyMapper;
import com.wskh.edu.service.StatisticsDailyService;
import com.wskh.eduCenter.service.UcenterMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author wskh
 * @since 2021-10-22
 */
@RestController
@RequestMapping("/eduService/statistics-daily")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    StatisticsDailyService statisticsDailyService;
    @Autowired
    StatisticsDailyMapper statisticsDailyMapper;

    @GetMapping(value = "countregister/{day}")
    public R registerCount(
            @PathVariable String day){
        int count = statisticsDailyMapper.countRegisterByDay(day);
        return R.ok().data("countRegister", count);
    }

    @PostMapping("{day}")
    public R createStatisticsByDate(@PathVariable String day) {
        statisticsDailyService.createStatisticsByDay(day);
        return R.ok();
    }

    @GetMapping("show-chart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,@PathVariable String
            end,@PathVariable String type){
        Map<String, Object> map = statisticsDailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }

}

